﻿@using CoralNode.MvcClient.Helper
@{
    ViewBag.Title = "来源分析";
    ViewBag.PageModule = "source";
    ViewBag.CurrentPageUrl = "/m/statistic/source?charttype=" + ViewBag.dateselect + "&chartContent=" + ViewBag.chartContent + "&";
}
@Html.IncludePage("CoralAdmin/statistic", "_Left")
<!--content-->
<div id="pbody">
    <div class="extra">
        @Html.IncludePage("CoralAdmin/statistic", "DateSelection")
        <div class="main-box mt_2 mb_2">
            <div class="tab-visit clearfix">
                <a class="current" href="/m/statistic/source?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">来源分类统计</a>
                @*<a href="/m/statistic/sourcelog?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">来源明细</a>
                    <a href="/m/statistic/sourceengine?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">搜索引擎统计</a>*@
                <a href="/m/statistic/sourceenginekey?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">搜索词统计</a>
            </div>
            <div class="clearfix h_49">
                <div class="visit-trend">
                    <div class="t clearfix">
                        <div class="f_l">
                            <select id="chartContentSelection">
                                <option @if (ViewBag.chartContent != "pv") { @String.Format("selected=selected") } value="session">来访次数</option>
                                <option @if (ViewBag.chartContent == "pv") { @String.Format("selected=selected") } value="pv">站内浏览总次数</option>
                            </select>
                        </div>
                        <div class="filter_btn  filter_btn-2 f_r">
                            <a class="w_3 @if (ViewBag.charttype == "area") {@String.Format("current") }" href="/m/statistic/source?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselect&chartContent=@ViewBag.chartContent&charttype=area"><i class="ico ico_chart_1"></i></a>
                            <a class="w_3 @if (ViewBag.charttype == "line") {@String.Format("current") }" href="/m/statistic/source?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselect&chartContent=@ViewBag.chartContent&charttype=line"><i class="ico ico_chart_2"></i></a>
                            <a class="w_3 last @if (ViewBag.charttype == "pie" || string.IsNullOrEmpty(ViewBag.charttype)) {@String.Format("current") }" href="/m/statistic/source?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselect&chartContent=@ViewBag.chartContent&charttype=pie"><i class="ico ico_chart_3"></i></a>
                        </div>
                    </div>
                    <div class="cnt_main mt_3" id="chartContainer"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/Themes/CoralAdmin/_misc/scripts/Highcharts/js/highcharts.src.js"></script>
<script type="text/javascript">
	    $(function () {
	        $("#chartContentSelection").change(function() {
	            window.location = "/m/statistic/source?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselect&charttype=@ViewBag.charttype&chartContent=" + $(this).val();
	        });
		  $('#chartContainer').highcharts({
            chart: {
                type: '@if (ViewBag.charttype == "line"){
                           @String.Format("line")
                       }else if (ViewBag.charttype == "pie") {
                           @String.Format("pie")
                       }else{@String.Format("area")}',
                spacingBottom: 30
            },
            title: {
                text: ''
            },

            legend: {
				  borderWidth: 0
			  },
            xAxis: {
                categories: [@Html.Raw(ViewBag.CategoriesStr)]
            },
            yAxis: {
                title: {
                    text: ''
                },
                labels: {
                    formatter: function() {
                        return this.value;
                    }
                }
            },
            tooltip: {
                @if (ViewBag.charttype != "pie") {
                    @Html.Raw(@"formatter: function() {
                        return '<b>'+ this.series.name +'</b><br/>'+
                        this.x +': '+ this.y;
                    },valueSuffix: '次'")
                } else {
                    @Html.Raw(@"formatter: function() {
                        return '<b>'+ this.point.name +'</b><br/>'+
                        this.series.name +': '+ this.y;
                    },valueSuffix: '次'")
                }
            },
            plotOptions: {
                area: {
                    fillOpacity: 0.5
                },
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
                        format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                    }
                }
            },
            credits: {
                enabled: false
            },
            series: [@Html.Raw(ViewBag.SeriesStr)]
		  });
	  });
</script>